//
//  MyZTHeaderView.m
//  CarTown
//
//  Created by xionghao on 15/8/25.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "MyZTHeaderView.h"

@implementation MyZTHeaderView
+(instancetype)header{
    MyZTHeaderView *myheader=[[[NSBundle mainBundle]loadNibNamed:@"MyZTHeaderView" owner:self options:nil]lastObject];
    return myheader;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)awakeFromNib{
    
    self.headpic.layer.cornerRadius=self.headpic.width/2;
    self.headpic.layer.borderColor=[tintblue CGColor];
    self.headpic.layer.borderWidth=0.5;
    self.headpic.userInteractionEnabled=YES;
    UIImageView *headerbgpic=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, XHScreenwidth, XHScreenwidth==320?120:140)];
    headerbgpic.contentMode=UIViewContentModeScaleAspectFill;
    headerbgpic.clipsToBounds=YES;
    headerbgpic.image=[UIImage imageNamed:@"userbgimg"];
    [self insertSubview: headerbgpic atIndex:0];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(bannerclick)];
    headerbgpic.userInteractionEnabled=YES;
    self.headerbgpic=headerbgpic;
    
    [self.headerbgpic addGestureRecognizer:tap];
    UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headpicclick)];
    [self.headpic addGestureRecognizer:tap1];
    UITapGestureRecognizer *titletap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(titleclick)];
    [self.titlelable addGestureRecognizer:titletap];
    UITapGestureRecognizer *lefttap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(leftclick)];
    [self.leftlable addGestureRecognizer:lefttap];
    UITapGestureRecognizer *midtap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(midclick)];
    [self.midlable addGestureRecognizer:midtap];
    self.leftlable.userInteractionEnabled=YES;
    self.midlable.userInteractionEnabled=YES;
}
- (IBAction)rightclick:(UIButton *)sender {
    if ([_delegate respondsToSelector:@selector(headbanclick:)]) {
        [_delegate headbanclick:4];
    }
}

-(void)titleclick{
    if ([_delegate respondsToSelector:@selector(headbanclick:)]) {
        [_delegate headbanclick:5];
    }
}

-(void)midclick{
    if ([_delegate respondsToSelector:@selector(headbanclick:)]) {
        [_delegate headbanclick:3];
    }
}

-(void)leftclick{
    if ([_delegate respondsToSelector:@selector(headbanclick:)]) {
        [_delegate headbanclick:2];
    }
}

-(void)bannerclick{
    if ([_delegate respondsToSelector:@selector(headbanclick:)]) {
        [_delegate headbanclick:0];
    }
}
-(void)headpicclick{
    if ([_delegate respondsToSelector:@selector(headbanclick:)]) {
        [_delegate headbanclick:1];
    }
}
@end
